package modules

import (
	"missevanbot/utils"
)

// GiftAdd adds number to the value that mapped by the key gift.
func GiftAdd(rid, uid int64, gift string, number int64) {
	key := prefixRoom(rid) + "gift:" + utils.Itoa(uid)
	rdb.HIncrBy(ctx, key, gift, number)
}

// GiftExists returns if gifts map exists.
func GiftExists(rid, uid int64) bool {
	key := prefixRoom(rid) + "gift:" + utils.Itoa(uid)
	return rdb.Exists(ctx, key).Val() != 0
}

// GiftGetRemove returns the gifts map (gift_name:gift_number),
// then delete the map.
func GiftGetRemove(rid, uid int64) (m map[string]string) {
	key := prefixRoom(rid) + "gift:" + utils.Itoa(uid)

	m = rdb.HGetAll(ctx, key).Val()
	rdb.Del(ctx, key)
	return
}
